@@ -15,8 +15,8 @@ from TimeConvert import TimeConvert as tc  | 
            ||
| 15 | 15 | 
                 | 
            
| 16 | 16 | 
                from account.models import UserInfo  | 
            
| 17 | 17 | 
                from coupon.models import UserCouponInfo  | 
            
| 18 | 
                -from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityGroupShareInfo, MemberActivityInfo,  | 
            |
| 19 | 
                - MemberActivitySigninInfo, MemberActivitySignupInfo, RightInfo)  | 
            |
| 18 | 
                +from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityContributionInfo, MemberActivityGroupShareInfo,  | 
            |
| 19 | 
                + MemberActivityInfo, MemberActivitySigninInfo, MemberActivitySignupInfo, RightInfo)  | 
            |
| 20 | 20 | 
                from utils.error.errno_utils import (MemberActivityStatusCode, MemberCouponStatusCode, MemberGoodStatusCode,  | 
            
| 21 | 21 | 
                MemberRightStatusCode, UserStatusCode)  | 
            
| 22 | 22 | 
                from utils.redis.connect import r  | 
            
                @@ -508,3 +508,34 @@ def activity_group_share(request):  | 
            ||
| 508 | 508 | 
                return response(400002, 'Activity has been offline', '会员活动已下线')  | 
            
| 509 | 509 | 
                 | 
            
| 510 | 510 | 
                return response()  | 
            
| 511 | 
                +  | 
            |
| 512 | 
                +  | 
            |
| 513 | 
                +@logit  | 
            |
| 514 | 
                +def activity_contribute(request):  | 
            |
| 515 | 
                +    brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
               | 
            |
| 516 | 
                +    user_id = request.POST.get('user_id', '')
               | 
            |
| 517 | 
                +    activity_id = request.POST.get('activity_id')
               | 
            |
| 518 | 
                + content_type = get_query_value(request, 'content_type', val_cast_type='int')  | 
            |
| 519 | 
                +    title = request.POST.get('title', '')
               | 
            |
| 520 | 
                +    content = request.POST.get('content', '')
               | 
            |
| 521 | 
                + images = get_query_value(request, 'images', val_cast_type='listjson')  | 
            |
| 522 | 
                +  | 
            |
| 523 | 
                + # 校验用户是否存在  | 
            |
| 524 | 
                + try:  | 
            |
| 525 | 
                + UserInfo.objects.get(user_id=user_id)  | 
            |
| 526 | 
                + except UserInfo.DoesNotExist:  | 
            |
| 527 | 
                + return response(UserStatusCode.USER_NOT_FOUND)  | 
            |
| 528 | 
                +  | 
            |
| 529 | 
                + contribution = MemberActivityContributionInfo.objects.create(  | 
            |
| 530 | 
                + brand_id=brand_id,  | 
            |
| 531 | 
                + user_id=user_id,  | 
            |
| 532 | 
                + activity_id=activity_id,  | 
            |
| 533 | 
                + content_type=content_type,  | 
            |
| 534 | 
                + title=title,  | 
            |
| 535 | 
                + content=content,  | 
            |
| 536 | 
                + images=images,  | 
            |
| 537 | 
                + )  | 
            |
| 538 | 
                +  | 
            |
| 539 | 
                +    return response(data={
               | 
            |
| 540 | 
                + 'contribution': contribution.data,  | 
            |
| 541 | 
                + })  | 
            
                @@ -228,6 +228,8 @@ urlpatterns += [  | 
            ||
| 228 | 228 | 
                 | 
            
| 229 | 229 | 
                url(r'^member/activity/group_share$', member_views.activity_group_share, name='member_activity_group_share'),  | 
            
| 230 | 230 | 
                 | 
            
| 231 | 
                + url(r'^member/activity/contribute$', member_views.activity_contribute, name='member_activity_contribute'),  | 
            |
| 232 | 
                +  | 
            |
| 231 | 233 | 
                url(r'^rights$', member_views.rights, name='rights'),  | 
            
| 232 | 234 | 
                url(r'^right/detail$', member_views.right_detail, name='right_detail'),  | 
            
| 233 | 235 | 
                url(r'^goods$', member_views.goods, name='goods'),  | 
            
                @@ -5,8 +5,9 @@ from django.contrib import admin  | 
            ||
| 5 | 5 | 
                from django_admin import DeleteModelAdmin  | 
            
| 6 | 6 | 
                 | 
            
| 7 | 7 | 
                from account.models import UserInfo  | 
            
| 8 | 
                -from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityGroupShareInfo, MemberActivityInfo,  | 
            |
| 9 | 
                - MemberActivitySigninInfo, MemberActivitySignupInfo, RightInfo, ShotTypeInfo)  | 
            |
| 8 | 
                +from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityContributionInfo, MemberActivityGroupShareInfo,  | 
            |
| 9 | 
                + MemberActivityInfo, MemberActivitySigninInfo, MemberActivitySignupInfo, RightInfo,  | 
            |
| 10 | 
                + ShotTypeInfo)  | 
            |
| 10 | 11 | 
                from pre.custom_message import sendwxasubscribemessage  | 
            
| 11 | 12 | 
                from utils.redis.rshot import update_member_shot_data  | 
            
| 12 | 13 | 
                 | 
            
                @@ -97,6 +98,11 @@ class MemberActivityGroupShareInfoAdmin(admin.ModelAdmin):  | 
            ||
| 97 | 98 | 
                     list_filter = ('is_integral', 'status')
               | 
            
| 98 | 99 | 
                 | 
            
| 99 | 100 | 
                 | 
            
| 101 | 
                +class MemberActivityContributionInfoAdmin(admin.ModelAdmin):  | 
            |
| 102 | 
                +    list_display = ('contribution_id', 'activity_id', 'content_type', 'title', 'content', 'images', 'status', 'created_at', 'updated_at')
               | 
            |
| 103 | 
                +    list_filter = ('activity_id', 'content_type', 'status')
               | 
            |
| 104 | 
                +  | 
            |
| 105 | 
                +  | 
            |
| 100 | 106 | 
                admin.site.register(GoodsInfo, GoodsInfoAdmin)  | 
            
| 101 | 107 | 
                admin.site.register(GoodsOrderInfo, GoodsOrderInfoAdmin)  | 
            
| 102 | 108 | 
                admin.site.register(RightInfo, RightInfoAdmin)  | 
            
                @@ -105,3 +111,4 @@ admin.site.register(MemberActivityInfo, MemberActivityInfoAdmin)  | 
            ||
| 105 | 111 | 
                admin.site.register(MemberActivitySignupInfo, MemberActivitySignupInfoAdmin)  | 
            
| 106 | 112 | 
                admin.site.register(MemberActivitySigninInfo, MemberActivitySigninInfoAdmin)  | 
            
| 107 | 113 | 
                admin.site.register(MemberActivityGroupShareInfo, MemberActivityGroupShareInfoAdmin)  | 
            
| 114 | 
                +admin.site.register(MemberActivityContributionInfo, MemberActivityContributionInfoAdmin)  | 
            
                @@ -0,0 +1,38 @@  | 
            ||
| 1 | 
                +# -*- coding: utf-8 -*-  | 
            |
| 2 | 
                +# Generated by Django 3.2.16 on 2022-10-23 06:42  | 
            |
| 3 | 
                +  | 
            |
| 4 | 
                +from django.db import migrations, models  | 
            |
| 5 | 
                +import jsonfield.fields  | 
            |
| 6 | 
                +import shortuuidfield.fields  | 
            |
| 7 | 
                +  | 
            |
| 8 | 
                +  | 
            |
| 9 | 
                +class Migration(migrations.Migration):  | 
            |
| 10 | 
                +  | 
            |
| 11 | 
                + dependencies = [  | 
            |
| 12 | 
                +        ('member', '0034_memberactivityinfo_limit_image_num'),
               | 
            |
| 13 | 
                + ]  | 
            |
| 14 | 
                +  | 
            |
| 15 | 
                + operations = [  | 
            |
| 16 | 
                + migrations.CreateModel(  | 
            |
| 17 | 
                + name='MemberActivityContributionInfo',  | 
            |
| 18 | 
                + fields=[  | 
            |
| 19 | 
                +                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
               | 
            |
| 20 | 
                +                ('status', models.BooleanField(default=True, help_text='Status', verbose_name='status')),
               | 
            |
| 21 | 
                +                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
               | 
            |
| 22 | 
                +                ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
               | 
            |
| 23 | 
                +                ('brand_id', models.CharField(blank=True, db_index=True, help_text='品牌唯一标识', max_length=32, null=True, verbose_name='brand_id')),
               | 
            |
| 24 | 
                +                ('brand_name', models.CharField(blank=True, help_text='品牌名称', max_length=255, null=True, verbose_name='brand_name')),
               | 
            |
| 25 | 
                +                ('contribution_id', shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='投稿唯一标识', max_length=22, null=True, unique=True)),
               | 
            |
| 26 | 
                +                ('user_id', models.CharField(blank=True, db_index=True, help_text='用户唯一标识', max_length=32, null=True, verbose_name='user_id')),
               | 
            |
| 27 | 
                +                ('activity_id', models.CharField(blank=True, db_index=True, help_text='活动唯一标识', max_length=32, null=True, verbose_name='activity_id')),
               | 
            |
| 28 | 
                +                ('content_type', models.IntegerField(choices=[(0, '投稿'), (1, '入围'), (2, '创作日记')], db_index=True, default=0, help_text='内容类型', verbose_name='content_type')),
               | 
            |
| 29 | 
                +                ('title', models.CharField(blank=True, help_text='标题', max_length=255, null=True, verbose_name='title')),
               | 
            |
| 30 | 
                +                ('content', models.TextField(blank=True, help_text='内容', null=True, verbose_name='content')),
               | 
            |
| 31 | 
                +                ('images', jsonfield.fields.JSONField(default=[], help_text='图片列表', verbose_name='images')),
               | 
            |
| 32 | 
                + ],  | 
            |
| 33 | 
                +            options={
               | 
            |
| 34 | 
                + 'verbose_name': '会员活动投稿信息',  | 
            |
| 35 | 
                + 'verbose_name_plural': '会员活动投稿信息',  | 
            |
| 36 | 
                + },  | 
            |
| 37 | 
                + ),  | 
            |
| 38 | 
                + ]  | 
            
                @@ -601,6 +601,7 @@ class MemberActivitySignupInfo(BaseModelMixin):  | 
            ||
| 601 | 601 | 
                @property  | 
            
| 602 | 602 | 
                def admindata(self):  | 
            
| 603 | 603 | 
                         return {
               | 
            
| 604 | 
                + 'signup_id': self.signup_id,  | 
            |
| 604 | 605 | 
                'user_id': self.user_id,  | 
            
| 605 | 606 | 
                'activity_id': self.activity_id,  | 
            
| 606 | 607 | 
                'title': self.title,  | 
            
                @@ -664,28 +665,50 @@ class MemberActivityGroupShareInfo(BaseModelMixin):  | 
            ||
| 664 | 665 | 
                 | 
            
| 665 | 666 | 
                 | 
            
| 666 | 667 | 
                class MemberActivityContributionInfo(BaseModelMixin):  | 
            
| 668 | 
                + CONTENT_TYPE = (  | 
            |
| 669 | 
                + (0, u'投稿'),  | 
            |
| 670 | 
                + (1, u'入围'),  | 
            |
| 671 | 
                + (2, u'创作日记'),  | 
            |
| 672 | 
                + )  | 
            |
| 673 | 
                +  | 
            |
| 667 | 674 | 
                brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)  | 
            
| 668 | 675 | 
                brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')  | 
            
| 669 | 676 | 
                 | 
            
| 670 | 
                - activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)  | 
            |
| 677 | 
                + contribution_id = ShortUUIDField(_(u'contribution_id'), max_length=32, blank=True, null=True, help_text=u'投稿唯一标识', db_index=True, unique=True)  | 
            |
| 671 | 678 | 
                 | 
            
| 672 | 
                - share_user_id = models.CharField(_(u'share_user_id'), max_length=32, blank=True, null=True, help_text=u'分享用户唯一标识', db_index=True)  | 
            |
| 673 | 
                - click_user_id = models.CharField(_(u'click_user_id'), max_length=32, blank=True, null=True, help_text=u'点击用户唯一标识', db_index=True)  | 
            |
| 679 | 
                + user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)  | 
            |
| 674 | 680 | 
                 | 
            
| 675 | 
                - open_gid = models.CharField(_(u'open_gid'), max_length=32, blank=True, null=True, help_text=u'群组唯一标识', db_index=True)  | 
            |
| 681 | 
                + activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)  | 
            |
| 676 | 682 | 
                 | 
            
| 677 | 
                - title = models.CharField(_(u'title'), max_length=255, blank=True, null=True, help_text=u'活动名称')  | 
            |
| 683 | 
                + content_type = models.IntegerField(_(u'content_type'), choices=CONTENT_TYPE, default=0, help_text=u'内容类型', db_index=True)  | 
            |
| 678 | 684 | 
                 | 
            
| 679 | 
                - is_integral = models.BooleanField(_(u'is_integral'), default=False, help_text=u'是否有积分')  | 
            |
| 680 | 
                - integral = models.IntegerField(_(u'integral'), default=0, help_text=u'积分')  | 
            |
| 685 | 
                + # 传参图片列表(默认第一张为封面图,包括图片url、宽、高)、标题、内容(纯文本)。  | 
            |
| 686 | 
                + title = models.CharField(_(u'title'), max_length=255, blank=True, null=True, help_text=u'标题')  | 
            |
| 687 | 
                + content = models.TextField(_(u'content'), blank=True, null=True, help_text=u'内容')  | 
            |
| 688 | 
                + # content_rich_text = RichTextField(_(u'content_rich_text'), blank=True, default='', help_text=u'内容')  | 
            |
| 689 | 
                +    # [{
               | 
            |
| 690 | 
                + # 'image_url': '',  | 
            |
| 691 | 
                + # 'width': 100,  | 
            |
| 692 | 
                + # 'height': 100,  | 
            |
| 693 | 
                + # }]  | 
            |
| 694 | 
                + images = JSONField(_(u'images'), default=[], help_text=u'图片列表')  | 
            |
| 681 | 695 | 
                 | 
            
| 682 | 696 | 
                class Meta:  | 
            
| 683 | 
                - verbose_name = _(u'会员活动群组分享信息')  | 
            |
| 684 | 
                - verbose_name_plural = _(u'会员活动群组分享信息')  | 
            |
| 685 | 
                -  | 
            |
| 686 | 
                - unique_together = (  | 
            |
| 687 | 
                -            ('activity_id', 'share_user_id', 'click_user_id', 'open_gid', 'brand_id'),
               | 
            |
| 688 | 
                - )  | 
            |
| 697 | 
                + verbose_name = _(u'会员活动投稿信息')  | 
            |
| 698 | 
                + verbose_name_plural = _(u'会员活动投稿信息')  | 
            |
| 689 | 699 | 
                 | 
            
| 690 | 700 | 
                def __unicode__(self):  | 
            
| 691 | 701 | 
                return '%d' % self.pk  | 
            
| 702 | 
                +  | 
            |
| 703 | 
                + @property  | 
            |
| 704 | 
                + def data(self):  | 
            |
| 705 | 
                +        return {
               | 
            |
| 706 | 
                + 'contribution_id': self.contribution_id,  | 
            |
| 707 | 
                + 'user_id': self.user_id,  | 
            |
| 708 | 
                + 'activity_id': self.activity_id,  | 
            |
| 709 | 
                + 'content_type': self.content_type,  | 
            |
| 710 | 
                + 'content_type_str': dict(MemberActivityContributionInfo.CONTENT_TYPE).get(self.content_type),  | 
            |
| 711 | 
                + 'title': self.title,  | 
            |
| 712 | 
                + 'content': self.content,  | 
            |
| 713 | 
                + 'images': self.images,  | 
            |
| 714 | 
                + }  |